// logs.js
const util = require('../../utils/util.js')
const {
  getU,PostURl
} = require('../../apis/index.js');


Page({
  data: {
    logs: [],
    ImgSRC: "https://img0.baidu.com/it/u=600722015,3838115472&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=750"

  },
  token() {
    // 存储  
    wx.setStorageSync('token', '123456789');
    // 读取  
    // const token = wx.getStorageSync('token');  
  },
  cancelToken() {
    wx.removeStorage({
      key: 'token',
      success(res) {
        console.log(res)
      }
    })
  },
  bindViewTap() {
    wx.navigateTo({
      url: '../index/index'
    })
  },
  bindViewTapA() {
    console.log("触发跳转");
    wx.navigateTo({
      url: '/packageA/pages/cat'
    })
  },
  async getUrl() {
    const U = await getU();
    this.setData({
      "ImgSRC": U.message
    })
  },
  async postUrl() {
    console.log("触发POST");
    const U = await PostURl();
    this.setData({
      "ImgSRC": U.message
    })
  },
  onLoad() {
    this.setData({
      logs: (wx.getStorageSync('logs') || []).map(log => {
        return {
          date: util.formatTime(new Date(log)),
          timeStamp: log
        }
      })
    })
  }
})